/*
* @(#)EmailMessageSorter.java
*
* Copyright (c) 2004 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
*/
package com.dcivision.mail.core;

import java.util.Arrays;
import java.util.List;

/**
 * EmailMessageSorter.java
 *
 * This class sort the email message
 *
 * @author      Beyond.Qu
 * @company     DCIVision Limited
 * @creation    14/01/2005
 * @version     $Revision: 1.6 $
 */
public class EmailMessageSorter {

  public static final String REVISION = "$Revision: 1.6 $";

  public static List sortEmailMessageList(List emailMessageList,String sortName,String sortOrder){
    Object[] a = emailMessageList.toArray();
    if(emailMessageList != null && emailMessageList.size() > 0){
//        Arrays.sort(a, new EmailMessageComparator(sortName,sortOrder));
        Arrays.sort(a, EmailMessageComparatorFactory.getInstance(sortName, sortOrder));
    }
    return Arrays.asList(a);
  }

  public static List sortEmailMessageList(List emailMessageList,String sortName){
    return sortEmailMessageList(emailMessageList, sortName, EmailMessageComparator.SORT_ASC);
  }
}
